/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author jefoutta
 */
//import java.io.IOException;
import java.io.IOException;
import java.util.*;

public class Terminal implements Runnable{

    private static Scanner input = new Scanner(System.in);
    private static String command;
    private static ArrayList<PCB> pcb = new ArrayList(0);
    public volatile static LinkedList<String> print_queue = new LinkedList();

    public void run(){
        //try {
        Registries initRegistries = new Registries();
        Scheduling scheduling = new Scheduling();
        while(true){
            command = input.nextLine();
            try {
                if (command.equals("stats"))
                    System.out.println(Scheduling.Stats());
                else
                pcb.add(new PCB(command));
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            
                this.checkPrint();
        }
    }
    
    public void checkPrint(){
            while(!print_queue.isEmpty()){
                System.out.println(print_queue.poll());
            }
    }
}
